home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-04-26 | 2.6 KB | 64 lines | [ TEXT/ttxt]
OpenDoc Development Framework Menu Resources ODF Release 1 ODF provides an easy way to create your part's menu bar in a cross-platform manner. To add a menubar to your part: • Create a text file with the extension .fr containing your menubar definition (see the syntax below). • Add this file to your project (if you are using Code Warrior) or to your MacMake.bmk file if you are using an MPW-based compiler. • In your part's Initialize method (override of FW_CPart::Initialize) call: GetMenuBar(ev)->InitializeFromResource(ev, <Your MenuBar resource ID>); • Don't forget to use the macro FW_DO_NOT_DEAD_STRIP if your menus contain toggle items or submenu items. ODF automatically calls this macro for text items and separator items but not for toggle and submenu items. The following menubar definition will create a menubar with two pulldown menus (Menu1 and Menu2). The first pulldown menu has six items (counting the two separator items) and the second one has two. The first pulldown menu also has a submenu. resource FW_RMenuBar(kMenuBar) { { FW_RPullDownMenu ( "Menu1" { FW_RTextItem(cCommand1, 'F', "Text Item 1"), FW_RTextItem(cCommand2, FW_kNoKeyEquivalent, "Text Item 2"), FW_RSeparatorItem(), FW_RSubMenuItem ( "SubMenu" { FW_RTextItem(cCommand3, FW_kNoKeyEquivalent, "Text Item 3"), FW_RTextItem(cCommand4, FW_kNoKeyEquivalent, "Text Item 4"), } ), FW_RSeparatorItem(), FW_RToggleItem(cCommand5, FW_kNoKeyEquivalent, "Hide", "Show"), } ), FW_RPullDownMenu ( "Menu2" { FW_RTextItem(cCommand6, 'R', "Text Item 6"), FW_RTextItem(cCommand7, FW_kNoKeyEquivalent, "Text Item 7"), } ) } }; • The convention used by ODF is to put constants used in both .fr resource files and C++ files into a file called "Defines.k". #define kMenuBar 1024 #define cCommand1 FW_kFirstUserCommandID © 1993 - 1996 Apple Computer, Inc. All rights reserved. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.